package edu.auctionmart

import static org.junit.Assert.*
import org.junit.*

class ProfileIntegrationTests {

    void testProfile() {
			
		Location testLocation = new Location(name: "Russell Gillen", addressLine: "50 USM Street", zipCode: "04103", town: "Portland", state: "ME")
		
		//Invalid phone number
		Profile invalidProfile = new Profile(contactPhoneNumber: 103, contactEmail: "rhgillen@gmail.com")
		invalidProfile.addToAddresses(testLocation)
		
		Profile validProfile = new Profile(contactPhoneNumber: 2074503879, contactEmail: "rhgillen@gmail.com")
		validProfile.addToAddresses(testLocation)
		
		invalidProfile.save()
		validProfile.save()
		
		def foundProfile = Profile.get(validProfile.id)
		assertNotNull(foundProfile)
		
		assertEquals 1, foundProfile.addresses.size()
		
		def notFoundProfile = Profile.get(invalidProfile.id)
		assertNull(notFoundProfile)	
	}
}